# eric7.DebugClients.Python.PyProfile

Module defining additions to the standard Python profile.py.

### Global Attributes

None

### Classes

PyProfile | Class extending the standard Python profiler with additional methods.

### Functions

None

## PyProfile

Class extending the standard Python profiler with additional methods.

This class extends the standard Python profiler by the functionality to save the collected timing data in a timing cache, to restore these data on subsequent calls, to store a profile dump to a standard filename and to erase these caches.

### Derived from

profile.Profile

### Class Attributes

dispatch

### Class Methods

None

### Methods

PyProfile | Constructor
__restore | Private method to restore the timing data from the timing cache.
dump_stats | Public method to dump the statistics data.
erase | Public method to erase the collected timing data.
fix_frame_filename | Public method used to fix up the filename for a given frame.
save | Public method to store the collected profile data.
trace_dispatch_call | Public method used to trace functions calls.

### Static Methods

None

#### PyProfile (Constructor)

PyProfile(basename, timer=None, bias=None)

Constructor

basename (str)
  name of the script to be profiled
timer (function)
  function defining the timing calculation
bias (float)
  calibration value

#### PyProfile.__restore

__restore()

Private method to restore the timing data from the timing cache.

#### PyProfile.dump_stats

dump_stats(file)

Public method to dump the statistics data.

file (str)
  name of the file to write to

#### PyProfile.erase

erase()

Public method to erase the collected timing data.

#### PyProfile.fix_frame_filename

fix_frame_filename(frame)

Public method used to fix up the filename for a given frame.

The logic employed here is that if a module was loaded from a .pyc file, then the correct .py to operate with should be in the same path as the .pyc. The reason this logic is needed is that when a .pyc file is generated, the filename embedded and thus what is readable in the code object of the frame object is the fully qualified filepath when the pyc is generated. If files are moved from machine to machine this can break debugging as the .pyc will refer to the .py on the original machine. Another case might be sharing code over a network... This logic deals with that.

frame (frame)
  frame object

Return:
  fixed up file name

Return Type:
  str

#### PyProfile.save

save()

Public method to store the collected profile data.

#### PyProfile.trace_dispatch_call

trace_dispatch_call(frame, t)

Public method used to trace functions calls.

This is a variant of the one found in the standard Python profile.py calling fix_frame_filename above.

frame (frame)
  reference to the call frame
t (list of Any)
  arguments

Return:
  flag indicating a successful handling

Return Type:
  int

Up